# female
ug3cb$sex_q2_1
ug3$female <- NA
ug3$female[ug3$sex_q2_1 == 2] <- 1
ug3$female[ug3$sex_q2_1 == 1] <- 0

# age_q2_3_c
ug3$age <- ug3$age_q2_3
ug3$age[!is.na(ug3$age_q2_3_c)] <- ug3$age_q2_3_c[!is.na(ug3$age_q2_3_c)]

# Vignette experiment on plausibility of mob vigilantism
names(ug3cb)
ug3cb$mob_violence_plausibility


# Treatments
ug3$accused_original <- ug3$accused
ug3$stranger_original <- ug3$stranger
ug3$observed_original <- ug3$observed
ug3$offense_original <- ug3$offense
ug3$victim_original <- ug3$victim
ug3$victim_stranger_original <- ug3$victim_stranger
ug3$instigator_original <- ug3$instigator
ug3$location_original <- ug3$location
ug3$beat_kill_original <- ug3$beat_kill
ug3$guilt_original <- ug3$guilt


ug3$accused_woman <- as.numeric(grepl("woman",ug3$accused,TRUE))
ug3$accused_is_stranger <- as.numeric(ug3$stranger == " ")
ug3$observed_committing <- as.numeric(grepl("observed",ug3$observed,TRUE))
ug3$offense_black_magic <- as.numeric(grepl("black magic",ug3$offense,TRUE))
ug3$victim_woman <- as.numeric(grepl("woman",ug3$victim,TRUE))
ug3$victim_is_stranger <- as.numeric(ug3$victim_stranger == "")
ug3$victim_instigates <- as.numeric(grepl("victim",ug3$instigator,TRUE))
ug3$happens_in_marketplace <- as.numeric(grepl("marketplace",ug3$location,TRUE))
ug3$mob_kills <- as.numeric(grepl("kill",ug3$beat_kill,TRUE))
ug3$called_perpetrator <- as.numeric(grepl("perpetrator",ug3$guilt,TRUE))

# Relevant treatment and outcome variables
ug3 <- 
  ug3 %>% 
  mutate(mob_could_happen = 1 - (mob_violence_plausibility == 1),
         target_accused = as.numeric(guilt_original == "accused "), 
         accused_man = 1 - accused_woman,
         mob_suspects = 1 - observed_committing, 
         interaction = case_when(
           (mob_suspects + target_accused + victim_instigates) == 3 ~ 1,
           (mob_suspects + target_accused + victim_instigates) == 0 ~ 0
         )
  )





# police_bribery_q11_8 (Satisfaction with police)
ug3cb$police_bribery_q11_8
ug3$police_not_bribe <- (ug3$police_bribery_q11_8 -1)/ 3

# who was asked the bribary question? (important for imputations)
ug3$state_capacity_prime <- (ug3$randomdraw11 <= 0.6)*1

table(ug3$state_capacity_prime, ug3$police_not_bribe, useNA = "always")

# widow_q12_1 (Support for mob violence)
ug3cb$widow_q12_1
ug3$demand_mobs_binary <- as.numeric(ug3$widow_q12_1 == 2)

# rights_accused_q12_2 (Demand for deterrence)
ug3cb$rights_accused_q12_2
ug3$punish_then_and_there <- as.numeric(ug3$rights_accused_q12_2 == 1)

# punishment_taste_q12_3 (Demand for punishment)
ug3cb$punishment_taste_q12_3
ug3$more_severe_punishment <- NA
ug3$more_severe_punishment <- ug3$punishment_taste_q12_3 - 1

